﻿<UserControl x:Class="Mengsk.ProxyDelivery.App.UI.Delivery.DeliveryScanUserControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="800" d:DesignWidth="1200" Loaded="UserControl_Loaded" FontSize="14">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="60"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="300"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*" MinHeight="100"/>
        </Grid.RowDefinitions>

        <StackPanel Grid.Row="0" Orientation="Horizontal">
            <!--<TextBlock Text="物流公司:" Margin="3" VerticalAlignment="Center"/>
            <ComboBox Name="cbbDeliveryCompanies" Margin="3" Width="150"/>-->
            <CheckBox Name="chkIngoreWeightDetect" Margin="3" VerticalAlignment="Center" Content="忽略重量检测" IsChecked="False"/>
            <CheckBox Name="chkIngorePopError" Margin="3" VerticalAlignment="Center" Content="忽略平台错误" IsChecked="False"/>
            <CheckBox Name="chkEnableInput" Margin="3" Content="手动输入重量" VerticalAlignment="Center"/>
            <TextBox Name="tbWeight" Margin="3" VerticalAlignment="Center" Width="60" IsEnabled="{Binding IsChecked, ElementName=chkEnableInput}" />
            <TextBlock Text="物流单号:" Margin="3" VerticalAlignment="Center"/>
            <TextBox Name="tbDeliveryNumber" Margin="3" Width="150" PreviewKeyDown="tbDeliveryNumber_PreviewKeyDown"/>
            <TextBlock Text="(使用条码枪扫描，或者手动输入后按回车键)" Margin="3" VerticalAlignment="Center"/>
        </StackPanel>

        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <TextBlock Grid.Column="0" Height="50" Text="扫描发货" Name="tbResult" Margin="5" FontFamily="黑体" FontWeight="ExtraBold" FontSize="42" VerticalAlignment="Center" HorizontalAlignment="Center"/>
            <TextBlock Grid.Column="1" Text="0 KG" Name="tbResultWeight" Margin="131,5,182,5" FontFamily="黑体" FontWeight="ExtraBold" FontSize="42" VerticalAlignment="Center" HorizontalAlignment="Center"/>
        </Grid>

        <StackPanel Grid.Row="3" Orientation="Horizontal" Name="spReceiver" >
            <TextBlock Text="订单编号:" Margin="3" VerticalAlignment="Center" FontSize="14"/>
            <TextBlock Text="{Binding Id}" Margin="3" VerticalAlignment="Center" FontSize="14"/>
            <TextBlock Text="商家编号:" Margin="3" VerticalAlignment="Center" FontSize="14"/>
            <TextBlock Text="{Binding SellerId}" Margin="3" VerticalAlignment="Center" FontSize="14"/>
            <TextBlock Text="创建时间:" Margin="3" VerticalAlignment="Center" FontSize="14"/>
            <TextBlock Text="{Binding CreateTime,Converter={StaticResource datetimeConverter}}" Margin="3" VerticalAlignment="Center" FontSize="14"/>
            <TextBlock Margin="3" VerticalAlignment="Center" FontSize="14" Text="收货人信息:"/>
            <TextBlock Text="{Binding ReceiverName}" Margin="3" VerticalAlignment="Center" FontSize="14"/>
            <TextBlock Text="{Binding Mobile}" Margin="3" VerticalAlignment="Center"  FontSize="14"/>
            <TextBlock Text="{Binding Phone}" Margin="3" VerticalAlignment="Center"  FontSize="14"/>
            <TextBlock Text="{Binding ReceiverAddress}" VerticalAlignment="Center"  FontSize="14"/>
        </StackPanel>

        <Grid Grid.Row="4">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="1*"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="1*"/>
            </Grid.ColumnDefinitions>
            <ListBox Grid.Column="0" Name="lstItems" ScrollViewer.CanContentScroll="False">
                <ListBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <WrapPanel></WrapPanel>
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>
                <ListBox.ItemContainerStyle>
                    <Style TargetType="ListBoxItem">
                        <Setter Property="Margin" Value="3"/>
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate>
                                    <Grid>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="Auto"/>
                                        </Grid.RowDefinitions>

                                        <Image Source="{Binding Image,Converter={StaticResource webUrlImageConverter}}" Width="200" Height="200"/>
                                        <StackPanel Grid.Row="1" Orientation="Horizontal">
                                            <TextBlock Text="{Binding Vendor}" Margin="3" VerticalAlignment="Center"/>
                                            <TextBlock Text="{Binding Number}" Margin="3" VerticalAlignment="Center"/>
                                            <TextBlock Text="{Binding Edtion}" Margin="3" VerticalAlignment="Center"/>

                                        </StackPanel>
                                        <StackPanel Grid.Row="2" Orientation="Horizontal">
                                            <TextBlock Text="{Binding Color}" Margin="3" VerticalAlignment="Center"/>
                                            <TextBlock Text="{Binding Size}" Margin="3" VerticalAlignment="Center"/>
                                            <TextBlock Text="{Binding Count}" Margin="3" VerticalAlignment="Center"/>
                                        </StackPanel>
                                    </Grid>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </ListBox.ItemContainerStyle>
            </ListBox>

            <GridSplitter Grid.Column="1" Width="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>

            <Grid Grid.Column="2">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="100"/>
                </Grid.RowDefinitions>
                <WebBrowser  x:Name="wb1" Grid.Row="1"/>
                <GridSplitter Grid.Row="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"  Height="5"/>
                <TextBox Name="tbYTDebug" Grid.Row="3" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" />
                <StackPanel Orientation="Horizontal" Grid.Row="0" Panel.ZIndex="2">
                    <Button Name="btnInject" Content="注入圆通" Width="80" Margin="3" Click="btnInject_Click" HorizontalAlignment="Left" VerticalAlignment="Top"/>
                    <Button Name="btnBack" Content="后退" Width="80" Margin="3" IsEnabled="{Binding ElementName=wb1,Path=CanGoBack}" Click="btnBack_Click" HorizontalAlignment="Left" VerticalAlignment="Top"/>
                    <Button Name="btnForward" Content="前进" Width="80" Margin="3" IsEnabled="{Binding ElementName=wb1,Path=CanGoForward}" Click="btnForward_Click" HorizontalAlignment="Left" VerticalAlignment="Top"/>
                
                    <TextBlock Text="COD编号:" Margin="3" VerticalAlignment="Center" />
                    <TextBox Name="tbCodNumber" Margin="3" VerticalAlignment="Center" Width="200"/>
                    <Button Name="btnGet" Margin="3" Content="获取" Width="60" VerticalAlignment="Center" Click="btnGet_Click"/>
                    <Button Name="btnMark" Margin="3" Content="标记" Width="60" VerticalAlignment="Center" Click="btnMark_Click"/>
                </StackPanel>
            </Grid>
        </Grid>

        <GridSplitter Grid.Row="5" Height="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"></GridSplitter>

        <StackPanel Grid.Row="6" Orientation="Horizontal">
            <TextBlock  Text="已扫描快递单号:" FontSize="16" Margin="3" VerticalAlignment="Center" HorizontalAlignment="Left"/>
            <TextBlock  Name="tbTotal" Margin="3" VerticalAlignment="Center" FontSize="16"/>
            <Button Name="btnClearHistory" Content="清空记录"  Click="btnClearHistory_Click" Margin="3" VerticalAlignment="Center" Width="100" FontSize="16"/>
        </StackPanel>

        <DataGrid Grid.Row="7" GridLinesVisibility="All" AutoGenerateColumns="False" IsReadOnly="True" Name="dgvScanedItems">
            <DataGrid.Columns>
                <DataGridTextColumn Header="订单编号" Binding="{Binding OrderId}" Width="Auto"/>
                <DataGridTextColumn Header="卖家编号" Binding="{Binding SellerId}"  Width="Auto"/>
                <DataGridTextColumn Header="快递公司" Binding="{Binding DeliveryCompany}"   Width="Auto"/>
                <DataGridTextColumn Header="快递单号" Binding="{Binding DeliveryNumber}"   Width="Auto"/>
                <DataGridTextColumn Header="包裹重量" Binding="{Binding Weight,StringFormat=F2}"   Width="Auto"/>
                <DataGridTextColumn Header="扫描时间" Binding="{Binding Time,Converter={StaticResource datetimeConverter}}"   Width="Auto"/>
                <DataGridTextColumn Header="商品信息" Binding="{Binding OrderGoodsInfo}"    Width="Auto"/>
                <DataGridTextColumn Header="收货人信息" Binding="{Binding ReceiverInfo}"   Width="*"/>
            </DataGrid.Columns>
        </DataGrid>
    </Grid>
</UserControl>
